package controllers

import (
	"github.com/beego/beego/v2/server/web"
	"login/services"
)

type AuthController struct {
	web.Controller
}

// GenerateToken 生成登录 token
func (c *AuthController) GenerateToken() {
	token, err := services.GenerateToken()
	if err != nil {
		c.Data["json"] = map[string]interface{}{"error": "Error generating token"}
		c.ServeJSON()
		return
	}
	c.Data["json"] = map[string]interface{}{"token": token}
	c.ServeJSON()
}
